<?php

//服务器和数据库信息
$servername = "localhost";
$username = "root";
$password = "";
$dbName = "myDB";
$tableName = "myguest";
 
// 创建连接
$conn = new mysqli($servername, $username, $password, $dbName);
 
// 检测连接
if ($conn->connect_error) {
  die("连接失败: " . $conn->connect_error);
}

$sql = "SELECT * FROM $tableName ORDER BY firstname DESC";
$result = $conn->query($sql);
if ($result->num_rows > 0 ) {
  $row = mysqli_fetch_all($result);
  var_dump($row);
}